<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<% String path=request.getContextPath(); String basePath=request.getScheme()+ "://" + request.getServerName() + ":" + request.getServerPort() + path+ "/"; %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" >
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>">
<title>激活卡作废统计</title>
<%@ include file="/WEB-INF/jsp/common/common.jsp"%>
<script src="js/jquery.divbox.js" type="text/javascript"></script>
<style>
.h_30 {
	height: 30px;
}

.table_body_div {
	padding: 10px 15%;
}

.table_date {
	padding: 20px 0 20px 30%;
}

#date {
	margin-left: 10%;
}

.calendars {
	z-index: 10001;
}

.fr {
	float: right;
}

.fl {
	float: left;
}

.w_50 {
	width: 50%;
}
/* 清除浮动 */
.clear::after {
	clear:both;
	content:'.';
	display:block;
	width: 0;
	height: 0;
	visibility:hidden;
}/*==for FF/chrome/opera/IE8==*/
</style>
<script type="text/javascript">
	/* 初始化 start */
	$(function() {
		queryCardInfo(1)
	})
	/* 初始化 end */
	/* 查询作废卡   start */
	function queryCardInfo(displayPage){
 		var name= $("#name").val();
		loadCardData({current:displayPage,size:10,cardDefineName: name}); 
	}
	function loadCardData(param){
		var jsonDate;
		if(null != param && null != param.current){
			jsonDate =param;	
		}else{
			jsonDate={current:1,size:10};
		}
		$.openLoading();
 		$.ajax({
			url : "cancelCard/queryCancel",
			type : 'POST',
			async : true,
			dataType:'json',
			data: param,
			success : function(page) {
				$.closeLoading();
				var radioObj ="<input class='input_fxk' name='radioCard' type='radio' value='#'>";
				var fieldNames = "cardDefineId@TDH,name,pricelessType?{0:'有价';1:'非有价'},deptNo@TDH,deptName,minNo,maxNo,count,status?{0: '库存'; '1': '上交'; '2': '下发'; '3': '关联销售信息'; '4': '可激活/已缴费'; '5': '已激活'; '6': '作废'; '7': '锁定'},status@TDH";
				var tableContent = creatTable4(fieldNames, page, radioObj);
				var tableObj = $("#cardpageTable");
				tableObj.find("tbody").remove();
				tableObj.append(tableContent);
				
				var strPage = creatChannelPage(page.current,6,page.maxPage,"75");
				var pageDIV = $("#cardpageDIV");
				pageDIV[0].innerHTML="";
				pageDIV.append(strPage);
				bindradio();//点击单选按钮，该行高亮显示
			}
		}) 
	}

	
	//查看出库记录明细
	function queryAgentInfo4(current){
		var radioCard = $("input[name='radioCard']:checked");
		if(radioCard.val()!=undefined){
			var flagCardDefineId=1;
			var flagdeptNo=4;
			var flagStatus=10;
			var cardDefineId = radioCard.parent().parent().children(" td:eq("+flagCardDefineId+")").html();
			var deptNo = radioCard.parent().parent().children(" td:eq("+flagdeptNo+")").html();
			var status = radioCard.parent().parent().children(" td:eq("+flagStatus+")").html();
			var jsonDate={current:current,size:10,cardDefineId:cardDefineId,deptNo:deptNo,status:status};
			$.openLoading();
			$.ajax({
				url : "cancelCard/queryCancelDetail?"+new Date().getTime(),
				type : 'POST',
				async : true,
				dataType:'json',
				data:jsonDate,
				success : function(page) {
					$.closeLoading();
					if($.validate(page))return;
					if(page.data==null){
						$.message("error","查询失败");
						return ;
					}
					var str = ''
					$.each(page.data, function (i, name, cardNo, status) {
						str += '<tr><td>' + ((i + 1)+(parseInt(page.current)-1)*(parseInt(page.size))) + '</td><td>' + page.data[i].name + '</td><td>' + page.data[i].cardNo + '</td><td>';
						if(page.data[i].status=='0'){
							str +='库存'+'</td></tr>';
						}else if(page.data[i].status=='1'){
							str +='上交'+'</td></tr>';
						}else if(page.data[i].status=='2'){
							str +='下发'+'</td></tr>';
						}else if(page.data[i].status=='3'){
							str +='关联销售信息'+'</td></tr>';
						}else if(page.data[i].status=='4'){
							str +='已缴费/可激活'+'</td></tr>';
						}else if(page.data[i].status=='5'){
							str +='已激活'+'</td></tr>';
						}else if(page.data[i].status=='6'){
							str +='作废'+'</td></tr>';
						}else if(page.data[i].status=='7'){
							str +='锁定'+'</td></tr>';
						}
						console.log(str);
					});
					var tableObj = $("#agentInfo4Table tbody");
					tableObj.html(str);
					//var fieldNames = "{name:'number','data': null,'targets': 0 },name,cardNo,status?[{0:'库存'};{1:'上交'};{2:'下发'};{3:'关联销售信息'};{4:'可激活'};{5:'已激活'};{6:'已作废'};{7:'已锁定'}]";
					//var tableContent = creatTable4(fieldNames,page,null,null);
					//var tableObj = $("#agentInfo4Table");
					//tableObj.find("tbody").remove();
					//tableObj.append(tableContent);
					
					var strPage = creatChannelPage4(jsonDate.current,6,page.maxPage,"48");
					var pageDIV = $("#agentInfo4Page");
					pageDIV[0].innerHTML="";
					pageDIV.append(strPage);
					
					$('#agentInfo4Div').OpenDiv();
					bindradio();
				}
			});
		}else{
			$.message("error", "请选择一条记录");
		}		
	}
	/* 多选按钮高亮 start */
    function bindradio(){
		$("input[name='radioCard']").click(function(){
			$("input[name='radioCard']").parent().parent().removeClass("table_highlighter");
			$("input[name='radioCard']:checked").parent().parent().addClass("table_highlighter");
	   	});
    }
    /* 多选按钮高亮 end */
	// 统一 关闭  窗口
	function closeCurrentDIV(obj){
		$("#"+obj).CloseDiv();
	}
	/*重置*/
	function vreset(){
		$("#name").val("");
	}
	</script>
</head>
<body>
	<div class="current">
		<table class="current_table_1">
			<tbody>
				<tr class="f2">
					<td><img src="./images/current_1.jpg"></td>
					<td class="current_table_1_td"><img src="images/current_1.png">&nbsp;您现在的位置：&nbsp;
						<span style="color: #136bab;">激活卡管理 <span
							style="padding: 0 5px; font-weight: bold; line-height: 28px;">&gt;</span>
							激活卡作废<span
							style="padding: 0 5px; font-weight: bold; line-height: 28px;">&gt;</span>
							激活卡作废统计
					    </span>
					</td>
					<td><img src="./images/current_3.jpg"></td>
				</tr>
			</tbody>
		</table>
	</div>

	<table class="table_02" id="table">
		<tr>
			<td>
				<table class="search_table">
					<tr height="30px">
						<td width="25%" height="30">卡定义名称： <input name="name"
							id="name" type="text" class="input_text" maxlength="30" value="">
						</td>
						<td width="25%" height="30" >
						    <input type="button" class="input_button_1" id="searchBtn" value="查询" onClick="queryCardInfo(1)" />
						    &nbsp;&nbsp;<input type="button" class="input_button_1" id="searchBtn" value="重置" onclick="vreset()" /></td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td>
				<table class="search_table">
					<tr height="30px">
						<td width="30%" height="30">
							<input type="button"
								class="input_button_1" value="明细"
								onClick="queryAgentInfo4('1')" /> 
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<!-- 数据列表 start -->
		<tr>
			<td>
				<table id="cardpageTable" class="content_table_1">
					<thead>
						<tr class="f1">
							<th style="width: 5%;">选择</th>
							<th style="width: 18%;">卡定义名称</th>
							<th style="width: 9%;">卡类型</th>
							<th style="width: 26%;">机构代码</th>
							<th style="width: 14%;">最小卡号</th>
							<th style="width: 14%;">最大卡号</th>
							<th style="width: 7%;">张数</th>
							<th style="width: 7%;">卡状态</th>
						</tr>
					</thead>
					<tbody>
					</tbody>
				</table>
				<div id="cardpageDIV" class="page"></div>
			</td>
		</tr>
		<!-- 数据列表 end -->
	</table>
	<!--   	添加模板 DIV 默认隐藏-->
    <div id="agentInfo4Div"  style="display:none;overflow-y:auto; width:700px">
		<div class="table_title_div">
				<table class="table_title" style='width:100%;height: 20px;'>
					<tr>
					<td width="10%"></td>
					<td width="80%" id="interfaceName"></td>
					<td width="10%" align="right"><img src="/manager/images/closedown.gif" alt="关闭"  onclick="closeCurrentDIV('agentInfo4Div')"/></td>
					</tr>
				</table>
	     </div>	     
	     <br>	
	     <span style=" font-size:16px; font-weight:bold; text-align:left;color:#3876bf; line-height:17px;">作废明细</span>
	    <table class="table_02" id="agentInfo4Table" align="center">
	    	<thead>
				<tr class="f1">
                  <th style="width:65px">序号</th>
                  <th style="width:235px">卡定义名称</th>
                  <th style="width:235px">卡号</th>
                  <th style="width:165px">状态</th>
                </tr>
             </thead>
			 <tbody>
			 </tbody>
		</table>
		<div id="agentInfo4Page"  class="page"></div>		
		<div align="center">
		   <input class="input_button_3" name="" type="button" onclick="closeCurrentDIV('agentInfo4Div')" value="确定">&nbsp;&nbsp;
           <input class="input_button_3" name="" type="button" onclick="closeCurrentDIV('agentInfo4Div')" value="取消">
		</div>
	</div>
	<div id="Loading" style="display: none" align="center">
		<img src="./images/loading.gif" />
	</div>
</body>
</html>